package com.springboot.demo.date;

import java.time.Instant;
import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;

public class LocalDat {
    public static void main(String[] args) {
        Instant now = Instant.now();
        System.out.println("当前时间是：" + now);
        //1970 1 1
        long epochSecond = now.getEpochSecond();
        System.out.println("纪元时间： "+ epochSecond + "秒");
        LocalDate now1 = LocalDate.now();
        System.out.println("不包含时间： "+ now1 );

        LocalDate localDate = now1.plusDays(1);
        System.out.println("增加一天： "+localDate + "");
        LocalDate localDate1 = now1.minusMonths(1);
        System.out.println("减少一个月： "+localDate1 + "");
        LocalDate nextYears = now1.plusYears(1);
        System.out.println("增加一年： "+nextYears + "");


        LocalDate period = LocalDate.of(2022, 5, 6);
        LocalDate period1 = LocalDate.of(2022, 4, 6);
        Period between = Period.between(period, period1);
        System.out.println(between.getMonths());


    }
}
